<template>
  <div class="student-management-system">
    <h1 class="campus-title">温州理工滨海校区</h1>
    <input v-model="studentId" placeholder="请输入学号" class="input-field" />
    <button @click="searchStudent" class="search-button">搜索</button>
    <div v-if="studentInfo" class="student-info">
      <p>学生信息</p>
      <p>学号: {{ studentInfo.id }}</p>
      <p>姓名: {{ studentInfo.name }}</p>
      <p>年龄: {{ studentInfo.age }}</p>
      <p>专业: {{ studentInfo.major }}</p>
    </div>
    <div v-if="!studentInfo && searchPerformed" class="error-message">
      未找到对应的学生信息。
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      studentId: '',
      studentInfo: null,
      searchPerformed: false,
      students: [
        { id: '123456', name: '他是谁', age: 18, major: '计算机科学' },
        { id: '987654', name: '你是谁', age: 18, major: '计算机科学' },
        { id: '321654', name: '谁是他', age: 18, major: '计算机科学' },
        { id: '654321', name: '谁是你', age: 18, major: '计算机科学' }
      ]
    };
  },
  methods: {
    searchStudent() {
      this.searchPerformed = true;
      this.studentInfo = this.students.find(student => student.id === this.studentId) || null;
    }
  }
};
</script>

<style scoped>
.campus-title {
  text-align: center;
  margin: 20px 0;
}

.input-field {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-right: 10px;
}

.search-button {
  padding: 8px 16px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.search-button:hover {
  background-color: #0056b3;
}

.student-info {
  text-align: center;
  margin-top: 20px;
}

.error-message {
  text-align: center;
  color: red;
  margin-top: 10px;
}
</style>    